package cn.swh.guguanjia.controller;

import cn.swh.guguanjia.entity.Result;
import cn.swh.guguanjia.service.WorkOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@RestController
@RequestMapping("/mapper/admin/work")
public class WorkOrderController {

    /**
     * @Description
     * @Params
     * @return
     **/


    @Autowired
    WorkOrderService service;


    @RequestMapping("")
    public ModelAndView index() {
        return new ModelAndView("/work/admin/work.html");
    }

    @RequestMapping({"/toDetail", "/update.html"})
    public ModelAndView toDetail() {
        return new ModelAndView("/work/work-detail.html");
    }


    @RequestMapping("selectPage/{pageNum}/{pageSize}")
    public Result selectPage(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize, @RequestParam Map<String,Object> condition) {
        return new Result(service.selectPage(pageNum, pageSize, condition));
    }

    @RequestMapping("selectById/{id}")
    public Result selectById(@PathVariable("id") long id) {
        return new Result(service.selectById(id));
    }
}
